#include<stdio.h>
#include<string.h>
int main()
{
	int a[10000],n,i=1,people,k;
	memset(a,0,sizeof(a));
	scanf("%d",&n);
	people=n;
	for(k=0;;k++)
	{
		if(k==n)
		{
			k=-1;continue;
		}
		if(a[k]==1)
			continue;
		if((i++)%3==0)
		{
			people--;
			a[k]=1;
			if(people==1)
				break;
		}
	}
	for(i=0;i<n;i++)
		if(a[i]==0)
			break;
	printf("%d\n",i+1);
}
